﻿using HandyControl.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace HMI.Header
{
    /// <summary>
    /// HeaderBar.xaml 的交互逻辑
    /// </summary>
    public partial class HeaderBar : UserControl
    {
        public HeaderBar()
        {
            InitializeComponent();
        }
        public string TitleTxt
        {
            get { return Convert.ToString(title.Content); }
            set
            {
                title.Content = value;
            }
        }
        public bool _max = false;
        public bool max
        {
            get { return _max; }
            set
            {
                if (!value)
                {
                    Geometry geometry = Geometry.Parse("M1,1L1,9 9,9 9,1z M0,0L10,0 10,10 0,10z");
                    IconElement.SetGeometry(maxx, geometry);
                }
                else
                {
                    Geometry geometry = Geometry.Parse("M1,3L1,9 7,9 7,3z M3,1L3,2 8,2 8,7 9,7 9,1z M2,0L10,0 10,8 8,8 8,10 0,10 0,2 2,2z");
                    IconElement.SetGeometry(maxx, geometry);
                }
                _max = value;
            }
        }
        public static readonly RoutedEvent CloseEvent = EventManager.RegisterRoutedEvent("CloseFrm", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(HeaderBar));
        public event RoutedEventHandler CloseFrm
        {
            add { this.AddHandler(CloseEvent, value); }
            remove { this.RemoveHandler(CloseEvent, value); }
        }
        public void OnClosed(RoutedEventArgs e)
        {
            this.RaiseEvent(e);
        }
        private void closex_Click(object sender, RoutedEventArgs e)
        {
            RoutedEventArgs args = new RoutedEventArgs(CloseEvent);
            this.OnClosed(args);
        }

        public static readonly RoutedEvent MinEvent = EventManager.RegisterRoutedEvent("MinFrm", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(HeaderBar));
        public event RoutedEventHandler MinFrm
        {
            add { this.AddHandler(MinEvent, value); }
            remove { this.RemoveHandler(MinEvent, value); }
        }
        public void OnMin(RoutedEventArgs e)
        {
            this.RaiseEvent(e);
        }
        private void minx_Click(object sender, RoutedEventArgs e)
        {
            RoutedEventArgs args = new RoutedEventArgs(MinEvent);
            this.OnMin(args);
        }

        public static readonly RoutedEvent MaxEvent = EventManager.RegisterRoutedEvent("MaxFrm", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(HeaderBar));
        public event RoutedEventHandler MaxFrm
        {
            add { this.AddHandler(MaxEvent, value); }
            remove { this.RemoveHandler(MaxEvent, value); }
        }
        public void OnMax(RoutedEventArgs e)
        {
            if (max)
            {
                max = false;
                Geometry geometry = Geometry.Parse("M1,1L1,9 9,9 9,1z M0,0L10,0 10,10 0,10z");
                IconElement.SetGeometry(maxx, geometry);
            }
            else
            {
                max = true;
                Geometry geometry = Geometry.Parse("M1,3L1,9 7,9 7,3z M3,1L3,2 8,2 8,7 9,7 9,1z M2,0L10,0 10,8 8,8 8,10 0,10 0,2 2,2z");
                IconElement.SetGeometry(maxx, geometry);
            }
            this.RaiseEvent(e);
        }
        public string TitleName
        {
            get { return title.Content.ToString(); }
            set { title.Content = value; }
        }
        private void maxx_Click(object sender, RoutedEventArgs e)
        {
            RoutedEventArgs args = new RoutedEventArgs(MaxEvent);
            this.OnMax(args);
        }
    }



}

